*WHAT'S ACROSS THE BORDER?
*JHA, NEUMARK, AND RODRIGUEZ-LOPEZ

include directories.do



*CREATE CZONE DATA WITH 722 CZONES (137 MULTI, AND 585 NON MULTI)
use "`datadir'`s'cbp_czone_state_20ind_sample.dta", clear
*Drop DC (Sample excludes DC, Hawaii, and Alaska -- keep rest of country)
drop if czone==11304 & state==11


preserve
			collapse (sum) emp-workagepop (first) multi three sic87xx_desc, by(year czone sic87xx)
			tempfile temp1
			save `temp1', replace
restore


preserve
			bys sic87xx multi year: egen mw_avg=wtmean(max_mw), weight(workagepop)
			collapse (first) mw_avg, by(multi year)
			tempfile temp2
			save `temp2', replace
restore


use "`temp1'", clear
 
 *Sample excludes DC, Hawaii, and Alaska -- keep rest of country

* COMPARE AGGREGATES OF 137 CZONES VS 585 CZONES 
 collapse (sum) emp ap est (first) workagepop multi, by(year czone)
 collapse (sum) emp ap est workagepop, by(year multi)
 gen emppop=emp/workagepop
 gen epwap=ap/(emp)
 tsset multi year
 
 twoway (line est year if multi==1, lc(blue)) (line est year if multi==0, lc(red) lpattern(shortdash) yaxis(2)), legend(off)  xtitle("Year") scheme(s1color)  xlabel(1991 1995 1999 2003 2007 2011 2015 , valuelabel) ylabel(1600000 "1.6" 1700000 "1.7" 1800000 "1.8" 1900000 "1.9" 2000000 "2" 2100000 "2.1" 2200000 "2.2", axis(1)) ylabel(3900000 "3.9" 4200000 "4.2" 4500000 "4.5" 4800000 "4.8" 5100000 "5.1" 5400000 "5.4", axis(2)) ytitle("Establishments - 137 multi-state zones (millions)") ytitle("Establishments - rest of country (millions)", axis(2))
 gr export "`outfigdir'`s'figure2a.eps", replace
 
 twoway (line emp year if multi==1, lc(blue)) (line emp year if multi==0, lc(red) lpattern(shortdash) yaxis(2)), legend(off)  xtitle("Year") scheme(s1color)  xlabel(1991 1995 1999 2003 2007 2011 2015 , valuelabel) ylabel(26000000 "26" 27000000 "27" 28000000 "28" 29000000 "29" 30000000 "30" 31000000 "31" 32000000 "32" 33000000 "33" 34000000 "34", axis(1)) ylabel(60000000 "60" 63000000 "63" 66000000 "66" 69000000 "69" 72000000 "72" 75000000 "75" 78000000 "78" 81000000 "81", axis(2)) ytitle("Employment - 137 multi-state zones (millions)") ytitle("Employment - rest of country (millions)", axis(2))
 gr export "`outfigdir'`s'figure2b.eps", replace
 
 bys multi: sum emppop
 twoway (line emppop year if multi==1, lc(blue)) (line emppop year if multi==0, lc(red) lpattern(shortdash)), legend(off)  xtitle("Year") scheme(s1color) xlabel(1991 1995 1999 2003 2007 2011 2015 , valuelabel) ylabel(0.51 0.53 0.55 0.57 0.59)  ytitle("Employment-to-population ratio")
 gr export "`outfigdir'`s'figure2c.eps", replace
 
 twoway (line epwap year if multi==1, lc(blue)) (line epwap year if multi==0, lc(red) lpattern(shortdash)), legend(off)  xtitle("Year") scheme(s1color) xlabel(1991 1995 1999 2003 2007 2011 2015 , valuelabel) ylabel(20 25 30 35 40 45 50) ytitle("Earnings per worker (thousands)")
 gr export "`outfigdir'`s'figure2d.eps", replace

 clear
 

* COMPARE INDUSTRIES OF INTEREST (sic87xx==5800 |  sic87xx==5200)

 use "`temp1'", clear
 collapse (sum) emp est ap, by(sic87xx multi year)
 bys year multi: egen totemp=total(emp)
 bys year multi: egen totest=total(est)
 gen epwap=ap/(emp)
 gen empshare=emp/totemp
 gen estshare=est/totest
 keep if sic87xx==5800 
 bys sic87xx multi: sum estshare empshare
 merge m:1 multi year using "`temp2'", nogenerate
 sort sic87xx multi year 
 
 *Minimum wage (does not matter which industry)
 twoway (line mw_avg year if multi==1 & sic87xx==5800, lc(blue)) (line mw_avg year if multi==0 & sic87xx==5800, lc(red) lpattern(shortdash)), legend(off)  xtitle("Year") scheme(s1color) xlabel(1991 1995 1999 2003 2007 2011 2015 , valuelabel) ylabel(4 4.5 5 5.5 6 6.5 7 7.5 8 8.5)  ytitle("Average minimum wage")
 gr export "`outfigdir'`s'figure2e.eps", replace
 
 twoway (line est year if multi==1 & sic87xx==5800, lc(blue)) (line est year if multi==0 & sic87xx==5800 , lc(red) lpattern(shortdash) yaxis(2)), legend(off)  xtitle("Year") scheme(s1color) xlabel(1991 1995 1999 2003 2007 2011 2015 , valuelabel) ylabel(90000 "90" 100000 "100" 110000 "110" 120000 "120" 130000 "130" 140000 "140" 150000 "150" 160000 "160" 170000 "170" 180000 "180", axis(1)) ylabel(220000 "220" 250000 "250" 280000 "280" 310000 "310"  340000 "340" 370000 "370" 400000 "400" 430000 "430", axis(2)) ytitle("Establishments - 137 multi-state zones (thousands)") ytitle("Establishments - rest of country (thousands)", axis(2))
 gr export "`outfigdir'`s'figureA1a.eps", replace
 
 twoway (line estshare year if multi==1 & sic87xx==5800, lc(blue)) (line estshare year if multi==0 & sic87xx==5800, lc(red) lpattern(shortdash)), legend(off)  xtitle("Year") scheme(s1color) xlabel(1991 1995 1999 2003 2007 2011 2015 , valuelabel) ylabel(0.06 "6%" 0.065 "6.5%" 0.07 "7%" 0.075 "7.5%" 0.08 "8%")  ytitle("Share of establishments")
 gr export "`outfigdir'`s'figureA1b.eps", replace
 
 twoway (line emp year if multi==1 & sic87xx==5800, lc(blue)) (line emp year if multi==0 & sic87xx==5800, lc(red) lpattern(shortdash) yaxis(2)), legend(off)  xtitle("Year") scheme(s1color) xlabel(1991 1995 1999 2003 2007 2011 2015 , valuelabel) ylabel(1700000 "1.7" 1900000 "1.9" 2100000 "2.1" 2300000 "2.3" 2500000 "2.5" 2700000 "2.7" 2900000 "2.9" 3100000 "3.1" 3300000 "3.3", axis(1)) ylabel(4000000 "4" 4500000 "4.5" 5000000 "5" 5500000 "5.5" 6000000 "6" 6500000 "6.5" 7000000 "7" 7500000 "7.5" 8000000 "8", axis(2)) ytitle("Employment - 137 multi-state zones (millions)") ytitle("Employment - rest of country (millions)", axis(2))
 gr export "`outfigdir'`s'figureA1c.eps", replace

 twoway (line epwap year if multi==1 & sic87xx==5800, lc(blue)) (line epwap year if multi==0 & sic87xx==5800, lc(red) lpattern(shortdash)), legend(off)  xtitle("Year") scheme(s1color) xlabel(1991 1995 1999 2003 2007 2011 2015 , valuelabel) ylabel(8 10 12 14 16 18)  ytitle("Earnings per worker (thousands)")
 gr export "`outfigdir'`s'figureA1d.eps", replace
 
clear

